import { createStore } from 'vuex';
import createPersistedState from 'vuex-persistedstate'

const store = createStore({
  state: () => ({
    token: "",
    userInfo: {
      openid:""
    },
  }),
  getters: {
    token: (state) => state.token,
    userInfo: (state) => state.userInfo,
  },
  mutations: {
    setToken(state, value) {
      state.token = value;
    },
    setUserInfo(state, value) {
      state.userInfo = value;
    }
  },
  actions: {},
  modules: {},
  plugins: [
    createPersistedState({
      key: 'wechatMsg_mobile',
      // 也可以是sessionstorage
      storage: window.localStorage
    })
  ]
});
export default store;